//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.web.controller.finance;

import com.aidong.dao.wills.PayListDao;
import com.aidong.service.ReportUploadService;
import com.aidong.web.controller.BaseController;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({"changtai"})
public class ChangTaiController extends BaseController {
    @Resource
    PayListDao payListDao;
    @Resource
    ReportUploadService reportUploadService;

    public ChangTaiController() {
    }

    @RequestMapping({"list"})
    public ModelAndView list() {
        ArrayList shopList = new ArrayList();
        if(this.isShopTypeCenter() || "SH044".equalsIgnoreCase(this.getLoginShopCode())) {
            shopList.add(new String[]{"SH044", "长泰广场"});
        }

        if(this.isShopTypeCenter() || "HZ002".equalsIgnoreCase(this.getLoginShopCode())) {
            shopList.add(new String[]{"HZ002", "杭州万象"});
        }

        if(this.isShopTypeCenter() || "SH061".equalsIgnoreCase(this.getLoginShopCode())) {
            shopList.add(new String[]{"SH061", "近铁绿洲"});
        }

        if(this.isShopTypeCenter() || "SH063".equalsIgnoreCase(this.getLoginShopCode())) {
            shopList.add(new String[]{"SH063", "宝山正大乐城"});
        }

        if(this.isShopTypeCenter() || "SH070".equalsIgnoreCase(this.getLoginShopCode())) {
            shopList.add(new String[]{"SH070", "徐汇正大乐城"});
        }

        if(this.isShopTypeCenter() || "BJ004".equalsIgnoreCase(this.getLoginShopCode())) {
            shopList.add(new String[]{"BJ004", "北京宜家"});
        }

        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dt1 = sdf.format(cal.getTime());
        return (new ModelAndView("finance/changtai/list")).addObject("shopList", shopList).addObject("dt1", dt1).addObject("dt2", dt1);
    }

    @RequestMapping({"_list"})
    public ModelAndView _list(@RequestParam(value = "shopCode",required = false) String shopCode, @RequestParam(value = "dateFrom",required = false) String dateFrom, @RequestParam(value = "dateTo",required = false) String dateTo, @RequestParam(value = "pageNo",required = false) String pageNo, @RequestParam(value = "totalCount",required = false) String totalCount) {
        if(this.chkNull(dateFrom) && this.chkNull(dateTo)) {
            SimpleDateFormat shop = new SimpleDateFormat("yyyy-MM-dd");
            dateFrom = shop.format(new Date());
            dateTo = dateFrom;
        } else if(this.chkNull(dateFrom)) {
            dateFrom = dateTo;
        } else if(this.chkNull(dateTo)) {
            dateTo = dateFrom;
        }

        String shop1 = "";
        List list = null;
        if("SH044".equalsIgnoreCase(shopCode)) {
            shop1 = "长泰广场";
            list = this.payListDao.getSumBySaleTypeChangTai("SH044", this.getDateFrom(dateFrom), this.getDateTo(dateTo));
        } else if("HZ002".equalsIgnoreCase(shopCode)) {
            shop1 = "杭州万象";
            list = this.payListDao.getSumBySaleTypeWanXiang("HZ002", this.parseDate(dateFrom, "yyyy-MM-dd"), this.parseDate(dateTo + " 23:59:59", "yyyy-MM-dd HH:mm:ss"));
        } else if("SH061".equalsIgnoreCase(shopCode)) {
            shop1 = "近铁绿洲";
            list = this.payListDao.getSumBySaleTypeSH061("SH061", this.parseDate(dateFrom, "yyyy-MM-dd"), this.parseDate(dateTo + " 23:59:59", "yyyy-MM-dd HH:mm:ss"));
        } else if("SH063".equalsIgnoreCase(shopCode)) {
            shop1 = "宝山正大乐城";
            list = this.payListDao.getSumBySaleTypeSH063("SH063", this.parseDate(dateFrom, "yyyy-MM-dd"), this.parseDate(dateTo + " 23:59:59", "yyyy-MM-dd HH:mm:ss"));
        } else if("SH070".equalsIgnoreCase(shopCode)) {
            shop1 = "徐汇正大乐城";
            list = this.payListDao.getSumBySaleTypeSH063("SH070", this.parseDate(dateFrom, "yyyy-MM-dd"), this.parseDate(dateTo + " 23:59:59", "yyyy-MM-dd HH:mm:ss"));
        } else if("BJ004".equalsIgnoreCase(shopCode)) {
            shop1 = "北京宜家";
            list = this.payListDao.getSumBySaleTypeBJ004("BJ004", this.parseDate(dateFrom, "yyyy-MM-dd"), this.parseDate(dateTo + " 23:59:59", "yyyy-MM-dd HH:mm:ss"));
        }

        ModelAndView mv = new ModelAndView("finance/changtai/_list");
        mv.addObject("list", list);
        mv.addObject("shop", shop1);
        return mv;
    }

    @RequestMapping({"_upl"})
    @ResponseBody
    public String _upl(@RequestParam(value = "date",required = false) String date) {
        if(this.chkNull(date)) {
            return this.getResult(false, "date");
        } else if("HZ002".equalsIgnoreCase(this.getLoginShopCode())) {
            this.reportUploadService.doWanXiangUpload(date);
            return this.getResult(true, "");
        } else if("SH061".equalsIgnoreCase(this.getLoginShopCode())) {
            this.reportUploadService.doSH061Upload(date);
            return this.getResult(true, "");
        } else if("SH063".equalsIgnoreCase(this.getLoginShopCode())) {
            this.reportUploadService.doSH063Upload(date);
            return this.getResult(true, "");
        } else if("SH070".equalsIgnoreCase(this.getLoginShopCode())) {
            this.reportUploadService.doSH070Upload(date);
            return this.getResult(true, "");
        } else if("BJ004".equalsIgnoreCase(this.getLoginShopCode())) {
            this.reportUploadService.doBJ004Upload(date);
            return this.getResult(true, "");
        } else {
            return this.getResult(false, "shop");
        }
    }
}
